package com.ruoyi.finance.rules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.finance.rules.entity.SzOtherRule;
import com.ruoyi.finance.rules.entity.SzVipRule;
import com.ruoyi.finance.rules.mapper.SzOtherRuleMapper;
import com.ruoyi.finance.rules.mapper.SzUserMapper;
import com.ruoyi.finance.rules.mapper.SzVipRuleMapper;
import com.ruoyi.finance.rules.service.RulescommonService;
import com.ruoyi.finance.rules.task.SZRuleCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RulescommonServiceImpl implements RulescommonService {

    @Autowired
    private SzVipRuleMapper szVipRuleMapper;

    @Autowired
    private SzOtherRuleMapper szOtherRuleMapper;

    @Autowired
    private SzUserMapper szUserMapper;

    @Autowired
    private SZRuleCache ruleCache;

    @Override
    public List<Map<Long, String>> listSzVipRule() {
        return szVipRuleMapper.listSzVipRule();
    }

    @Override
    public List<Map<String, String>> dmcTable(String code) {
        return szVipRuleMapper.dmcTable(code);
    }

    @Override
    public Map<String, Object> getOtherRule() {
        return szOtherRuleMapper.selectCount(new LambdaQueryWrapper<>()) != 0 ?
                szOtherRuleMapper.selectMaps(new LambdaQueryWrapper<SzOtherRule>().select(SzOtherRule::getPricing, SzOtherRule::getEnergy, SzOtherRule::getRevenueRatio, SzOtherRule::getExtractRatio)).get(0) :
                null;
    }

    @Override
    public List<Map<String, String>> listSzUserSimple(String userId) {
        return szUserMapper.listSzUserSimple(userId,"");
    }


}
